package com.app.twth.ui.mine;

import android.content.Intent;

import androidx.viewbinding.ViewBinding;

import com.app.twth.app.AppRouter;
import com.app.twth.app.Constant;
import com.app.twth.app.MyApplication;
import com.app.twth.base.BaseFragment;
import com.app.twth.databinding.FragmentMineBinding;
import com.app.twth.ui.login.LoginActivity;
import com.app.twth.ui.mine.version.VersionActivity;
import com.app.twth.utils.PreferencesUtil;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;


public class MineFragment extends BaseFragment {

    private FragmentMineBinding binding;

    @Override
    protected ViewBinding getViewBinding() {
        binding = FragmentMineBinding.inflate(getLayoutInflater());
        return binding;
    }

    @Override
    protected void initListener() {
        binding.version.setOnClickListener(v -> {
            AppRouter.showFragmentActivity(mContext, VersionActivity.class);
        });
        binding.vLogout.setOnClickListener(v -> {
            MyApplication.token = "";
            PreferencesUtil.putString(mContext, Constant.location, "");
            PreferencesUtil.putString(mContext, Constant.token, "");
            startActivity(new Intent(mContext, LoginActivity.class));
            mContext.finish();
        });
    }

    @Override
    protected void initData() {
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMainThread(Object object) {
    }

}
